home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************
- *
- Copyright © 1995 - 1998, 3Com Corporation or its subsidiaries ("3Com").
- All rights reserved.
-
- This software may be copied and used solely for developing products for
- the Palm Computing platform and for archival and backup purposes. Except
- for the foregoing, no part of this software may be reproduced or transmitted
- in any form or by any means or used to make any derivative work (such as
- translation, transformation or adaptation) without express written consent
- from 3Com.
-
- 3Com reserves the right to revise this software and to make changes in content
- from time to time without obligation on the part of 3Com to provide notification
- of such revision or changes.
- 3COM MAKES NO REPRESENTATIONS OR WARRANTIES THAT THE SOFTWARE IS FREE OF ERRORS
- OR THAT THE SOFTWARE IS SUITABLE FOR YOUR USE. THE SOFTWARE IS PROVIDED ON AN
- "AS IS" BASIS. 3COM MAKES NO WARRANTIES, TERMS OR CONDITIONS, EXPRESS OR IMPLIED,
- EITHER IN FACT OR BY OPERATION OF LAW, STATUTORY OR OTHERWISE, INCLUDING WARRANTIES,
- TERMS, OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
- SATISFACTORY QUALITY.
-
- TO THE FULL EXTENT ALLOWED BY LAW, 3COM ALSO EXCLUDES FOR ITSELF AND ITS SUPPLIERS
- ANY LIABILITY, WHETHER BASED IN CONTRACT OR TORT (INCLUDING NEGLIGENCE), FOR
- DIRECT, INCIDENTAL, CONSEQUENTIAL, INDIRECT, SPECIAL, OR PUNITIVE DAMAGES OF
- ANY KIND, OR FOR LOSS OF REVENUE OR PROFITS, LOSS OF BUSINESS, LOSS OF INFORMATION
- OR DATA, OR OTHER FINANCIAL LOSS ARISING OUT OF OR IN CONNECTION WITH THIS SOFTWARE,
- EVEN IF 3COM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
- 3Com, HotSync, Palm Computing, and Graffiti are registered trademarks, and
- Palm III and Palm OS are trademarks of 3Com Corporation or its subsidiaries.
-
- IF THIS SOFTWARE IS PROVIDED ON A COMPACT DISK, THE OTHER SOFTWARE AND
- DOCUMENTATION ON THE COMPACT DISK ARE SUBJECT TO THE LICENSE AGREEMENT
- ACCOMPANYING THE COMPACT DISK.
-
- *************************************************************************
- *
- * PROJECT: Pilot
- * FILE: Starter.c
- * AUTHOR: Roger Flores: May 20, 1997
- *
- * DECLARER: Starter
- *
- * DESCRIPTION:
- *
- *
- **********************************************************************/
- #include <Pilot.h>
- #include <SysEvtMgr.h>
- #include "StarterRsc.h"
-
-
-
- /***********************************************************************
- *
- * Entry Points
- *
- ***********************************************************************/
-
-
- /***********************************************************************
- *
- * Internal Structures
- *
- ***********************************************************************/
- typedef struct
- {
- Byte replaceme;
- } StarterPreferenceType;
-
- typedef struct
- {
- Byte replaceme;
- } StarterAppInfoType;
-
- typedef StarterAppInfoType* StarterAppInfoPtr;
-
-
- /***********************************************************************
- *
- * Global variables
- *
- ***********************************************************************/
- //static Boolean HideSecretRecords;
-
-
- /***********************************************************************
- *
- * Internal Constants
- *
- ***********************************************************************/
- #define appFileCreator 'strt'
- #define appVersionNum 0x01
- #define appPrefID 0x00
- #define appPrefVersionNum 0x01
-
-
- // Define the minimum OS version we support
- #define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
-
-
- #define fauxLaunch -1
-
-
- FormPtr prevForm;
-
- RectanglePtr gDrawRect;
- Boolean gAbout, gShade, gMain;
-
-
- /***********************************************************************
- *
- * Internal Functions
- *
- ***********************************************************************/
-
-
- /***********************************************************************
- *
- * FUNCTION: RomVersionCompatible
- *
- * DESCRIPTION: This routine checks that a ROM version is meet your
- * minimum requirement.
- *
- * PARAMETERS: requiredVersion - minimum rom version required
- * (see sysFtrNumROMVersion in SystemMgr.h
- * for format)
- * launchFlags - flags that indicate if the application
- * UI is initialized.
- *
- * RETURNED: error code or zero if rom is compatible
- *
- * REVISION HISTORY:
- *
- ***********************************************************************/
- static Err RomVersionCompatible(DWord requiredVersion, Word launchFlags)
- {
- DWord romVersion;
-
- // See if we're on in minimum required version of the ROM or later.
- FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
- if (romVersion < requiredVersion)
- {
- if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
- (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
- {
- FrmAlert (RomIncompatibleAlert);
-
- // Pilot 1.0 will continuously relaunch this app unless we switch to
- // another safe one.
- if (romVersion < sysMakeROMVersion(2,0,0,sysROMStageRelease,0))
- AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
- }
-
- return (sysErrRomIncompatible);
- }
-
- return (0);
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: GetObjectPtr
- *
- * DESCRIPTION: This routine returns a pointer to an object in the current
- * form.
- *
- * PARAMETERS: formId - id of the form to display
- *
- * RETURNED: VoidPtr
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static VoidPtr GetObjectPtr(Word objectID)
- {
- FormPtr frmP;
-
-
- frmP = FrmGetActiveForm();
- return (FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: MainFormInit
- *
- * DESCRIPTION: This routine initializes the MainForm form.
- *
- * PARAMETERS: frm - pointer to the MainForm form.
- *
- * RETURNED: nothing
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static void MainFormInit(FormPtr frmP)
- {
- }
-
-
- static Boolean HandleAboutForm(EventPtr eventP)
- {
- Boolean handled = false;
- FormPtr frm;//, prevForm;
- Word hitButton;
- RectanglePtr r = MemPtrNew( sizeof( RectangleType ) );
- MenuBarPtr theMenuBar;
- WinHandle w;
- CharPtr chars;
- Word index;
- WordPtr num;
- Handle h;
- SWord x, y, oldX, oldY;
-
-
- switch (eventP->eType) {
- case ctlSelectEvent:
- if ( prevForm ) {
- frm = FrmGetActiveForm();
- FrmEraseForm( frm );
- FrmDeleteForm( frm );
-
- FrmSetActiveForm( prevForm );
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
- }
-
- handled = true;
- break;
-
- case frmOpenEvent:
- frm = FrmGetActiveForm();
- FrmDrawForm( frm );
-
- FrmGetFormBounds( frm, gDrawRect );
-
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
-
- r->topLeft.x = 2;
- r->topLeft.y = 2;
- r->extent.x = 8;
- r->extent.y = 8;
- WinDrawRectangle( r, 0 );
-
- WinDrawLine( 0, 12, 150, 12 );
-
- index = FrmGetObjectIndex( frm, AboutVersionStringLabel );
- FrmGetObjectBounds( frm, index, r );
-
- chars = SysGetOSVersionString();
- WinDrawChars( chars, StrLen( chars ), r->topLeft.x, r->topLeft.y );
-
- // hitButton = FrmDoDialog( frm );
-
- if ( prevForm ) {
- FrmSetActiveForm( prevForm );
- }
-
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
- // FrmDeleteForm( frm );
-
- if ( chars )
- MemPtrFree( chars );
-
- handled = true;
- break;
-
- case penUpEvent:
- break;
-
- case penDownEvent:
- oldX = x = eventP->screenX;
- oldY = y = eventP->screenY;
- frm = FrmGetActiveForm();
- index = FrmGetObjectIndex( frm, 1104 );
- FrmGetObjectBounds( frm, index, r );
-
- r->topLeft.x = 2;
- r->topLeft.y = 2;
- r->extent.x = 8;
- r->extent.y = 8;
-
- if ( RctPtInRectangle( x, y, r ) ) {
- break;
-
- if ( prevForm ) {
- FrmEraseForm( frm );
- FrmDeleteForm( frm );
-
- FrmSetActiveForm( prevForm );
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
- // MenuSetActiveMenu( NULL );
- }
-
- handled = true;
- }
- else {
- r->topLeft.x = 12;
- r->topLeft.y = 0;
- r->extent.x = 148;
- r->extent.y = 12;
-
- if ( RctPtInRectangle( x, y, r ) ) {
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
-
- handled = true;
-
- while ( handled ) {
- EvtGetPen( &x, &y, &handled );
- /*
- if ( x == oldX )
- r->topLeft.x;
- else if ( x < oldX )
- r->topLeft.x = oldX - ( oldX - x );
- else if ( x > oldX )
- r->topLeft.x = oldX + ( x - oldX );
-
- if ( y == oldY )
- r->topLeft.y;
- else if ( y < oldY )
- r->topLeft.y = oldY - ( oldY - y );
- else if ( y > oldY )
- r->topLeft.y = oldY + ( y - oldY );
-
- r->extent.x = 150;
- r->extent.y = 50;
-
- WinFillRectangle( r, 0 );
- WinDrawRectangleFrame( roundFrame, r );
- */
- }
-
- if ( x == oldX && y == oldY )
- break;
-
- FrmGetFormBounds( frm, r );
-
- FrmEraseForm( frm );
- WinFillRectangle( r, 0 );
-
- // x = oldX + ( x - oldX );
-
-
- if ( x == oldX )
- r->topLeft.x;
- else if ( x < oldX )
- r->topLeft.x = oldX - ( oldX - x );
- else if ( x > oldX )
- r->topLeft.x = oldX + ( x - oldX );
-
- if ( y == oldY )
- r->topLeft.y;
- else if ( y < oldY )
- r->topLeft.y = oldY - ( oldY - y );
- else if ( y > oldY )
- r->topLeft.y = oldY + ( y - oldY );
-
- // r->topLeft.x = ( oldX <= x ) ? oldX + ( x - oldX ) : oldX - ( oldX - x );
- // r->topLeft.y = oldY + ( y - oldY );
- // r->extent.x = r->extent.x;
- // r->extent.y = r->extent.y;
-
- // WinFillRectangle( r, 0 );
- // WinDrawRectangleFrame( roundFrame, r );
- // FrmDrawForm( frm );
-
- r->topLeft.x = x + 2;
- r->topLeft.y = y + 2;
- r->extent.x = 8;
- r->extent.y = 8;
- /*
- WinDrawRectangleFrame( rectangleFrame, r );
- // WinDrawRectangle( r, 0 );
-
- WinDrawLine( x, y + 12, x + 150, y + 12 );
-
- WinDrawLine( x + 13, y + 2, x + 32, y + 2 );
- WinDrawLine( x + 13, y + 4, x + 32, y + 4 );
- WinDrawLine( x + 13, y + 6, x + 32, y + 6 );
- WinDrawLine( x + 13, y + 8, x + 32, y + 8 );
-
- WinDrawLine( x + 123, y + 2, x + 147, y + 2 );
- WinDrawLine( x + 123, y + 4, x + 147, y + 4 );
- WinDrawLine( x + 123, y + 6, x + 147, y + 6 );
- WinDrawLine( x + 123, y + 8, x + 147, y + 8 );
- */
- index = FrmGetObjectIndex( frm, AboutVersionStringLabel );
- FrmGetObjectBounds( frm, index, r );
-
- chars = SysGetOSVersionString();
- WinDrawChars( chars, StrLen( chars ), x + r->topLeft.x, x + r->topLeft.y );
-
- // hitButton = FrmDoDialog( frm );
-
- if ( prevForm ) {
- // FrmSetActiveForm( prevForm );
- // theMenuBar = MenuGetActiveMenu();
- // theMenuBar = MenuInit( FinderMenuBar );
- // MenuSetActiveMenu( NULL );
- // MenuDrawMenu( theMenuBar );
- }
-
- // FrmDeleteForm( frm );
-
- if ( chars )
- MemPtrFree( chars );
-
- }
-
- handled = true;
- }
-
- break;
- default:
- break;
-
- }
-
- return handled;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: MainFormDoCommand
- *
- * DESCRIPTION: This routine performs the menu command specified.
- *
- * PARAMETERS: command - menu item id
- *
- * RETURNED: nothing
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static Boolean MainFormDoCommand(Word command)
- {
- Boolean handled = false;
- // FormPtr prevForm;
- FormPtr frm;
- Word hitButton;
- RectanglePtr r = MemPtrNew( sizeof( RectangleType ) );
- MenuBarPtr theMenuBar;
- WinHandle w;
- CharPtr chars;
- Word index;
- WordPtr num;
- Handle h;
-
- switch (command) {
- case AppleAboutThisComputer:
- prevForm = FrmGetActiveForm();
- /*
- frm = FrmInitForm( AboutForm );
-
- FrmSetActiveForm( frm );
- FrmSetEventHandler( frm, HandleAboutForm );
-
- FrmDrawForm ( frm );
- w = FrmGetWindowHandle( frm );
- */
- w = FrmGetWindowHandle( prevForm );
- WinSetDrawWindow( w );
-
- // Main window.
- r->topLeft.x = 5;
- r->topLeft.y = 40;
- r->extent.x = 150;
- r->extent.y = 50;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Close box.
- r->topLeft.x += 3;
- r->topLeft.y += 3;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade.
- r->topLeft.x += 137;
- r->topLeft.y;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade filler.
- WinDrawLine( r->topLeft.x, r->topLeft.y + 1, r->topLeft.x + 6, r->topLeft.y + 1 );
- WinDrawLine( r->topLeft.x, r->topLeft.y + 4, r->topLeft.x + 6, r->topLeft.y + 4 );
-
- gDrawRect->topLeft.x = r->topLeft.x = 5;
- gDrawRect->topLeft.y = r->topLeft.y = 40;
- gDrawRect->extent.x = r->extent.x = 150;
- gDrawRect->extent.y = r->extent.y = 50;
-
- WinDrawLine( r->topLeft.x, r->topLeft.y + 12, r->topLeft.x + r->extent.x, r->topLeft.y + 12 );
-
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 2, r->topLeft.x + 29, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 4, r->topLeft.x + 29, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 6, r->topLeft.x + 29, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 8, r->topLeft.x + 29, r->topLeft.y + 8 );
-
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 2, r->topLeft.x + 134, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 4, r->topLeft.x + 134, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 6, r->topLeft.x + 134, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 8, r->topLeft.x + 134, r->topLeft.y + 8 );
-
- WinDrawChars( "About This Computer", StrLen( "About This Computer" ), r->topLeft.x + 32, r->topLeft.y );
- WinDrawChars( "Palm Finder 1.0", StrLen( "Palm Finder 1.0" ), r->topLeft.x + 45, r->topLeft.y + 20 );
- WinDrawChars( "PalmOS", StrLen( "PalmOS" ), r->topLeft.x + 45, r->topLeft.y + 35 );
-
- chars = SysGetOSVersionString();
- WinDrawChars( chars, StrLen( chars ), r->topLeft.x + 80, r->topLeft.y + 35 );
-
- if ( chars )
- MemPtrFree( chars );
-
- gAbout = true;
-
- handled = true;
- break;
-
- default:
- break;
-
- }
-
- if ( r )
- MemPtrFree( r );
-
- return handled;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: MainFormHandleEvent
- *
- * DESCRIPTION: This routine is the event handler for the
- * "MainForm" of this application.
- *
- * PARAMETERS: eventP - a pointer to an EventType structure
- *
- * RETURNED: true if the event has handle and should not be passed
- * to a higher level handler.
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static Boolean MainFormHandleEvent(EventPtr eventP)
- {
- Boolean handled = false;
- // FormPtr prevForm;
- FormPtr frm, tempFrm;
- MenuBarPtr theMenuBar;
- Word index, origIndex, tps;
- RectanglePtr r = MemPtrNew( sizeof( RectangleType ) );
- BitmapPtr b;
- Word hitButton;
- WinHandle w, saveWin;
- CharPtr chars = MemPtrNew( 32 );
- WordPtr num;
- Handle h;
- SWord x, y, oldX, oldY;
- ULong numTicks, oldTime;
-
- frm = FrmGetActiveForm();
-
- oldX = x = eventP->screenX;
- oldY = y = eventP->screenY;
-
- switch (eventP->eType) {
- case penDownEvent:
- if ( gAbout ) {
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
-
- // index = FrmGetObjectIndex( frm, 1104 );
- // FrmGetObjectBounds( frm, index, r );
-
- // Check close.
- r->topLeft.x = gDrawRect->topLeft.x + 3;
- r->topLeft.y = gDrawRect->topLeft.y + 3;
- r->extent.x = 6;
- r->extent.y = 6;
-
- if ( RctPtInRectangle( x, y, r ) ) {
- r->topLeft.x = gDrawRect->topLeft.x - 1;
- r->topLeft.y = gDrawRect->topLeft.y - 1;
- r->extent.x = gDrawRect->extent.x + 2;
- r->extent.y = gDrawRect->extent.y + 2;
-
- WinFillRectangle( r, 0 );
-
- if ( prevForm ) {
- FrmSetActiveForm( prevForm );
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
- }
-
- gAbout = false;
- handled = true;
- break;
- }
-
- // Check shade.
- r->topLeft.x = gDrawRect->topLeft.x + gDrawRect->extent.x - 12;
- r->topLeft.y = gDrawRect->topLeft.y + 3;
- r->extent.x = 6;
- r->extent.y = 6;
-
- if ( RctPtInRectangle( x, y, r ) ) {
- if ( !gShade ) {
- r->topLeft.x = gDrawRect->topLeft.x - 1;
- r->topLeft.y = gDrawRect->topLeft.y + 13;
- r->extent.x = gDrawRect->extent.x + 2;
- r->extent.y = gDrawRect->extent.y - 12;
-
- WinFillRectangle( r, 0 );
- }
- else {
- // Main window.
- r->topLeft.x = gDrawRect->topLeft.x;
- r->topLeft.y = gDrawRect->topLeft.y;
- r->extent.x = gDrawRect->extent.x;
- r->extent.y = gDrawRect->extent.y;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Close box.
- r->topLeft.x += 3;
- r->topLeft.y += 3;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade.
- r->topLeft.x += 137;
- r->topLeft.y;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade filler.
- WinDrawLine( r->topLeft.x, r->topLeft.y + 1, r->topLeft.x + 6, r->topLeft.y + 1 );
- WinDrawLine( r->topLeft.x, r->topLeft.y + 4, r->topLeft.x + 6, r->topLeft.y + 4 );
-
- r->topLeft.x = gDrawRect->topLeft.x;
- r->topLeft.y = gDrawRect->topLeft.y;
- r->extent.x = gDrawRect->extent.x;
- r->extent.y = gDrawRect->extent.y;
-
- WinDrawLine( r->topLeft.x, r->topLeft.y + 12, r->topLeft.x + r->extent.x, r->topLeft.y + 12 );
-
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 2, r->topLeft.x + 29, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 4, r->topLeft.x + 29, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 6, r->topLeft.x + 29, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 8, r->topLeft.x + 29, r->topLeft.y + 8 );
-
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 2, r->topLeft.x + 134, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 4, r->topLeft.x + 134, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 6, r->topLeft.x + 134, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 8, r->topLeft.x + 134, r->topLeft.y + 8 );
-
- WinDrawChars( "About This Computer", StrLen( "About This Computer" ), r->topLeft.x + 32, r->topLeft.y );
- WinDrawChars( "Palm Finder 1.0", StrLen( "Palm Finder 1.0" ), r->topLeft.x + 45, r->topLeft.y + 20 );
- WinDrawChars( "PalmOS", StrLen( "PalmOS" ), r->topLeft.x + 45, r->topLeft.y + 35 );
-
- chars = SysGetOSVersionString();
- WinDrawChars( chars, StrLen( chars ), r->topLeft.x + 80, r->topLeft.y + 35 );
-
- if ( chars )
- MemPtrFree( chars );
- }
-
- gShade = !gShade;
-
- handled = true;
- break;
- }
-
- // Check drag.
- r->topLeft.x = gDrawRect->topLeft.x + 12;
- r->topLeft.y = gDrawRect->topLeft.y;
- r->extent.x = gDrawRect->extent.x - 24;
- r->extent.y = 12;
-
- if ( RctPtInRectangle( x, y, r ) ) {
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
-
- handled = true;
-
- while ( handled ) {
- EvtGetPen( &x, &y, &handled );
-
- // saveWin = WinSaveBits( gDrawRect, num );
-
- r->topLeft.x = gDrawRect->topLeft.x - 1;
- r->topLeft.y = gDrawRect->topLeft.y - 1;
- r->extent.x = gDrawRect->extent.x + 2;
- r->extent.y = gDrawRect->extent.y + 2;
-
- WinFillRectangle( r, 0 );
-
- if ( x == oldX )
- gDrawRect->topLeft.x;
- else if ( x < oldX )
- gDrawRect->topLeft.x = oldX - ( oldX - x );
- else if ( x > oldX )
- gDrawRect->topLeft.x = oldX + ( x - oldX );
-
- if ( y == oldY )
- gDrawRect->topLeft.y;
- else if ( y < oldY )
- gDrawRect->topLeft.y = oldY - ( oldY - y );
- else if ( y > oldY )
- gDrawRect->topLeft.y = oldY + ( y - oldY );
-
- // WinDrawRectangleFrame( rectangleFrame, gDrawRect );
-
- // Main window.
- r->topLeft.x = gDrawRect->topLeft.x;
- r->topLeft.y = gDrawRect->topLeft.y;
- r->extent.x = gDrawRect->extent.x;
- r->extent.y = gDrawRect->extent.y;
-
- if ( gShade ) {
- r->extent.y = 12;
- }
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Close box.
- r->topLeft.x += 3;
- r->topLeft.y += 3;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade.
- r->topLeft.x += 137;
- r->topLeft.y;
- r->extent.x = 6;
- r->extent.y = 6;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- // Window shade filler.
- WinDrawLine( r->topLeft.x, r->topLeft.y + 1, r->topLeft.x + 6, r->topLeft.y + 1 );
- WinDrawLine( r->topLeft.x, r->topLeft.y + 4, r->topLeft.x + 6, r->topLeft.y + 4 );
-
- r->topLeft.x = gDrawRect->topLeft.x;
- r->topLeft.y = gDrawRect->topLeft.y;
- r->extent.x = gDrawRect->extent.x;
- r->extent.y = gDrawRect->extent.y;
-
- WinDrawLine( r->topLeft.x, r->topLeft.y + 12, r->topLeft.x + r->extent.x, r->topLeft.y + 12 );
-
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 2, r->topLeft.x + 29, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 4, r->topLeft.x + 29, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 6, r->topLeft.x + 29, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 13, r->topLeft.y + 8, r->topLeft.x + 29, r->topLeft.y + 8 );
-
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 2, r->topLeft.x + 134, r->topLeft.y + 2 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 4, r->topLeft.x + 134, r->topLeft.y + 4 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 6, r->topLeft.x + 134, r->topLeft.y + 6 );
- WinDrawLine( r->topLeft.x + 120, r->topLeft.y + 8, r->topLeft.x + 134, r->topLeft.y + 8 );
-
- if ( !gShade ) {
- WinDrawChars( "About This Computer", StrLen( "About This Computer" ), r->topLeft.x + 32, r->topLeft.y );
- WinDrawChars( "Palm Finder 1.0", StrLen( "Palm Finder 1.0" ), r->topLeft.x + 45, r->topLeft.y + 20 );
- WinDrawChars( "PalmOS", StrLen( "PalmOS" ), r->topLeft.x + 45, r->topLeft.y + 35 );
-
- chars = SysGetOSVersionString();
- WinDrawChars( chars, StrLen( chars ), r->topLeft.x + 80, r->topLeft.y + 35 );
-
- if ( chars )
- MemPtrFree( chars );
- }
-
- // WinRestoreBits( saveWin, x, y );
- }
-
- handled = true;
- break;
- }
- }
-
- // Check drive icon.
- // x = eventP->screenX;
- // y = eventP->screenY;
- // frm = FrmGetActiveForm();
-
- index = FrmGetObjectIndex( frm, MainDriveBitMap );
- origIndex = index;
- FrmGetObjectBounds( frm, index, r );
-
- if ( RctPtInRectangle( x, y, r ) ) {
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
-
- // index = FrmGetObjectIndex( frm, MainDriveMaskBitMap );
- h = MemHandleNew( 255 );
- h = DmGet1Resource( 'PICT', DriveMaskBitmap );
- b = ( BitmapPtr )MemHandleLock( h );
- // b = ( BitmapPtr )DmGetResource( 'PICT', DriveMaskBitmap );
- WinDrawBitmap( b, r->topLeft.x, r->topLeft.y );
- DmReleaseResource( h );
- MemHandleUnlock( h );
- MemHandleFree( h );
-
- r->topLeft.x -= 1;
- r->extent.x = 0;
- r->extent.y = 0;
-
- tps = SysTicksPerSecond();
-
- index = 0;
-
- oldTime = TimGetTicks();
-
- while ( index < 4 ) {
- numTicks = TimGetTicks();
-
- if ( numTicks >= ( oldTime + ( tps / 4 ) ) ) {
- if ( index > 0 ) {
- r->topLeft.x -= 1;
- r->topLeft.y -= 1;
- r->extent.x += 2;
- r->extent.y += 2;
-
- WinFillRectangle( r, 0 );
-
- r->topLeft.x += 1;
- r->topLeft.y += 1;
- r->extent.x -= 2;
- r->extent.y -= 2;
- }
-
- r->topLeft.x -= 25;
- r->topLeft.y += 5;
- r->extent.x += 25;
- r->extent.y += 20;
-
- WinDrawRectangleFrame( rectangleFrame, r );
-
- oldTime = numTicks;
- index++;
- }
- }
-
- gMain = true;
- }
-
- break;
-
- case menuEvent:
- frm = FrmGetActiveForm();
-
- if ( FrmGetFormPtr( AboutForm ) != frm )
- handled = MainFormDoCommand(eventP->data.menu.itemID);
-
- break;
-
- case frmOpenEvent:
- frm = FrmGetActiveForm();
- MainFormInit( frm );
- FrmDrawForm ( frm );
- /*
- w = FrmGetWindowHandle( frm );
- WinSetDrawWindow( w );
- index = FrmGetObjectIndex( frm, MainDriveMaskBitMap );
- b = ( BitmapPtr )FrmGetObjectPtr( frm, index );
- WinDrawBitmap( b, 200, 200 );
- */
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
-
- handled = true;
- break;
-
- default:
- break;
-
- }
-
- if ( r )
- MemPtrFree( r );
-
- return handled;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: AppHandleEvent
- *
- * DESCRIPTION: This routine loads form resources and set the event
- * handler for the form loaded.
- *
- * PARAMETERS: event - a pointer to an EventType structure
- *
- * RETURNED: true if the event has handle and should not be passed
- * to a higher level handler.
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static Boolean AppHandleEvent( EventPtr eventP)
- {
- Word formId, index;
- FormPtr frmP;
-
- if (eventP->eType == frmLoadEvent)
- {
- // Load the form resource.
- formId = eventP->data.frmLoad.formID;
- frmP = FrmInitForm(formId);
- FrmSetActiveForm(frmP);
-
- // index = FrmGetObjectIndex( frmP, MainDriveMaskBitMap );
- // FrmHideObject( frmP, index );
-
- // Set the event handler for the form. The handler of the currently
- // active form is called by FrmHandleEvent each time is receives an
- // event.
- switch (formId)
- {
- case MainForm:
- FrmSetEventHandler(frmP, MainFormHandleEvent);
- break;
-
- case AboutForm:
- FrmSetEventHandler( frmP, HandleAboutForm );
-
- default:
- ErrFatalDisplay("Invalid Form Load Event");
- break;
-
- }
- return true;
- }
-
- return false;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: AppEventLoop
- *
- * DESCRIPTION: This routine is the event loop for the application.
- *
- * PARAMETERS: nothing
- *
- * RETURNED: nothing
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static void AppEventLoop(void)
- {
- Word error;
- EventType event;
-
-
- do {
- EvtGetEvent(&event, evtWaitForever);
-
-
- if (! SysHandleEvent(&event))
- if (! MenuHandleEvent(0, &event, &error))
- if (! AppHandleEvent(&event))
- FrmDispatchEvent(&event);
-
- } while (event.eType != appStopEvent);
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: AppStart
- *
- * DESCRIPTION: Get the current application's preferences.
- *
- * PARAMETERS: nothing
- *
- * RETURNED: Err value 0 if nothing went wrong
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static Err AppStart(void)
- {
- StarterPreferenceType prefs;
- Word prefsSize;
-
-
- // Read the saved preferences / saved-state information.
- prefsSize = sizeof(StarterPreferenceType);
- if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
- noPreferenceFound)
- {
- }
-
- return 0;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: AppStop
- *
- * DESCRIPTION: Save the current state of the application.
- *
- * PARAMETERS: nothing
- *
- * RETURNED: nothing
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static void AppStop(void)
- {
- StarterPreferenceType prefs;
-
-
- // Write the saved preferences / saved-state information. This data
- // will be backed up during a HotSync.
- PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
- &prefs, sizeof (prefs), true);
- }
-
-
-
- /***********************************************************************
- *
- * FUNCTION: StarterPilotMain
- *
- * DESCRIPTION: This is the main entry point for the application.
- * PARAMETERS: cmd - word value specifying the launch code.
- * cmdPB - pointer to a structure that is associated with the launch code.
- * launchFlags - word value providing extra information about the launch.
- *
- * RETURNED: Result of launch
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- static DWord StarterPilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
- {
- Err error;
-
-
- error = RomVersionCompatible (ourMinVersion, launchFlags);
- if (error) return (error);
-
-
- switch (cmd)
- {
- case sysAppLaunchCmdNormalLaunch:
- error = AppStart();
- if (error)
- return error;
-
- gDrawRect = MemPtrNew( sizeof( RectangleType ) );
- gMain = gShade = gAbout = false;
-
- FrmGotoForm(MainForm);
- AppEventLoop();
- AppStop();
- break;
-
- default:
- break;
-
- }
-
- return 0;
- }
-
-
- /***********************************************************************
- *
- * FUNCTION: PilotMain
- *
- * DESCRIPTION: This is the main entry point for the application.
- *
- * PARAMETERS: cmd - word value specifying the launch code.
- * cmdPB - pointer to a structure that is associated with the launch code.
- * launchFlags - word value providing extra information about the launch.
- * RETURNED: Result of launch
- *
- * REVISION HISTORY:
- *
- *
- ***********************************************************************/
- DWord PilotMain( Word cmd, Ptr cmdPBP, Word launchFlags)
- {
- return StarterPilotMain(cmd, cmdPBP, launchFlags);
- }
-
- /*
- x = eventP->screenX;
- y = eventP->screenY;
- frm = FrmGetActiveForm();
- index = FrmGetObjectIndex( frm, MainDriveBitMap );
- origIndex = index;
- FrmGetObjectBounds( frm, index, r );
-
- if ( RctPtInRectangle( x, y, r ) ) {
-
- frm = FrmGetActiveForm();
- index = FrmGetObjectIndex( frm, MainDriveBitMap );
- FrmHideObject( frm, index );
- FrmSetObjectPosition( frm, index, 200, 200 );
-
- // index = FrmGetObjectIndex( frm, MainDriveMaskBitMap );
- // b = ( BitmapPtr )FrmGetObjectPtr( frm, index );
- // WinDrawBitmap( b, x, y );
- index = FrmGetObjectIndex( frm, MainDriveMaskBitMap );
- FrmShowObject( frm, index );
- FrmSetObjectBounds( frm, index, r );
-
- // FrmNewBitmap( &frm, DriveMaskBitmap, DriveMaskBitmap, x, y );
-
- MainFormDoCommand( fauxLaunch );
-
- // frm = FrmGetActiveForm();
- FrmHideObject( frm, index );
- FrmSetObjectPosition( frm, index, 200, 200 );
- // WinInvertRectangle( r, 0 );
-
- index = FrmGetObjectIndex( frm, MainDriveBitMap );
- // b = ( BitmapPtr )FrmGetObjectPtr( frm, index );
- // WinDrawBitmap( b, x, y );
- FrmShowObject( frm, index );
- FrmSetObjectPosition( frm, index, 135, 15 );
- // FrmNewBitmap( &frm, DriveBitmap, DriveBitmap, x, y );
- handled = true;
- }
- */
- /*
- case fauxLaunch:
- prevForm = FrmGetActiveForm();
- frm = FrmInitForm( NewWindowForm );
-
- FrmSetActiveForm( frm );
-
- r->topLeft.x = 2;
- r->topLeft.y = 2;
- r->extent.x = 8;
- r->extent.y = 8;
- WinDrawRectangle( r, 0 );
-
- h = MemHandleNew( 32 );
- SysCreateDataBaseList( 0, 0, num, &h,true);
-
- hitButton = FrmDoDialog( frm );
-
- if ( prevForm ) {
- FrmSetActiveForm( prevForm );
- theMenuBar = MenuInit( FinderMenuBar );
- MenuSetActiveMenu( theMenuBar );
- MenuDrawMenu( theMenuBar );
- }
-
- FrmDeleteForm( frm );
-
- handled = true;
- break;
- */
-